home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / architecture / hppa / alignment.h next >
Text File  |  1994-06-08  |  1KB  |  54 lines

  1. /*
  2.  * Copyright (c) 1992 NeXT Computer, Inc.
  3.  *
  4.  * Natural alignment of shorts and longs (for hppa)
  5.  *
  6.  * HISTORY
  7.  *
  8.  * 2 Sept 1992 Brian Raymor at NeXT
  9.  *      Moved over to architecture.
  10.  * 17 August 1992 Jack Greenfield at NeXT
  11.  *    Created.
  12.  */
  13.  
  14. __inline__ static unsigned short 
  15. get_align_short(void *ivalue)
  16. {
  17.     unsigned short    ovalue = ((unsigned char *) ivalue)[0];
  18.  
  19.     ovalue <<= 8 * sizeof(unsigned char);
  20.     return ovalue + ((unsigned char *) ivalue)[1];
  21. }
  22.  
  23. __inline__ static unsigned short 
  24. put_align_short(unsigned short ivalue, void *ovalue)
  25. {
  26.     unsigned short    *tvalue = &ivalue;
  27.  
  28.     ((unsigned char *) ovalue)[0] = ((unsigned char *) tvalue)[0];
  29.     ((unsigned char *) ovalue)[1] = ((unsigned char *) tvalue)[1];
  30.     return ivalue;
  31. }
  32.  
  33. __inline__ static unsigned long 
  34. get_align_long(void *ivalue)
  35. {
  36.     unsigned long    ovalue = get_align_short(ivalue);
  37.  
  38.     ovalue <<= 8 * sizeof(unsigned short);
  39.     return ovalue + get_align_short(((unsigned char *) ivalue) + sizeof(short));
  40. }
  41.  
  42. __inline__ static unsigned long 
  43. put_align_long(unsigned long ivalue, void *ovalue)
  44. {
  45.     unsigned long    *tvalue = &ivalue;
  46.  
  47.     ((unsigned char *) ovalue)[0] = ((unsigned char *) tvalue)[0];
  48.     ((unsigned char *) ovalue)[1] = ((unsigned char *) tvalue)[1];
  49.     ((unsigned char *) ovalue)[2] = ((unsigned char *) tvalue)[2];
  50.     ((unsigned char *) ovalue)[3] = ((unsigned char *) tvalue)[3];
  51.     return ivalue;
  52. }
  53.  
  54.